﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using LabMS.BLL;
using LabMS.Model;
using System.Data;
using Maticsoft.DBUtility;

namespace ExtendBLL
{
    public class PositionLog:LabMS.BLL.PositionLog
    {
        public string GetTeacherCode(string PLogTeacherName)
        {
            string TeacherCode = "";
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select t.Teacher_Code from Teacher t, positionlog p where p.PLog_TeacherCode = t.Teacher_Code and p.PLog_TeacherName = '");
            strSql.Append(PLogTeacherName);
            strSql.Append("'");

            DataSet ds = DbHelperSQL.Query(strSql.ToString());
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Teacher_Code"].ToString() != "")
                {
                    TeacherCode = ds.Tables[0].Rows[0]["Teacher_Code"].ToString();
                }
            }
            else
            {
                TeacherCode = "";
            }

            return TeacherCode;
        }

        public List<ExtendModule.PositionLog> GetExtendModuleList(string strAnd)
        {
            DataSet ds = dal.GetTotalPLogList(strAnd);
            List<ExtendModule.PositionLog> modelList = new List<ExtendModule.PositionLog>();
            int rowsCount = ds.Tables[0].Rows.Count;
            if (rowsCount > 0)
            {
                ExtendModule.PositionLog model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new ExtendModule.PositionLog();
                    if (ds.Tables[0].Rows[n]["ID"].ToString() != "")
                    {
                        model.ID = int.Parse(ds.Tables[0].Rows[n]["ID"].ToString());
                    }
                    if (ds.Tables[0].Rows[n]["PLog_Time"].ToString() != "")
                    {
                        model.PLog_Time = DateTime.Parse(ds.Tables[0].Rows[n]["PLog_Time"].ToString());
                    }
                    model.PLog_TeacherCode = ds.Tables[0].Rows[n]["PLog_TeacherCode"].ToString();
                    model.PLog_TeacherName = ds.Tables[0].Rows[n]["PLog_TeacherName"].ToString();
                    if (ds.Tables[0].Rows[n]["PLog_RecodeTime"].ToString() != "")
                    {
                        model.PLog_RecodeTime = DateTime.Parse(ds.Tables[0].Rows[n]["PLog_RecodeTime"].ToString());
                    }
                    model.PLog_LabIntro = ds.Tables[0].Rows[n]["PLog_LabIntro"].ToString();
                    model.PLog_Equipment = ds.Tables[0].Rows[n]["PLog_Equipment"].ToString();
                    model.PLog_Other = ds.Tables[0].Rows[n]["PLog_Other"].ToString();
                    model.PLog_IP = ds.Tables[0].Rows[n]["PLog_IP"].ToString();
                    model.PLog_TotalRecordCount = ds.Tables[0].Rows[n]["PLog_TotalRecordCount"].ToString();
                    modelList.Add(model);
                }
            }
            return modelList;
        }
    }
}
